import os
from django.db import connection, transaction
import settings
from forum_modules.pgfulltext.settings import PG_FTSTRIGGERS_VERSION

VERSION = 11

if int(PG_FTSTRIGGERS_VERSION) < VERSION:
    f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r')

    try:
        cursor = connection.cursor()
        cursor.execute(f.read())
        transaction.commit()

        PG_FTSTRIGGERS_VERSION.set_value(VERSION)

    except Exception as e:
        # import sys, traceback
        # traceback.print_exc(file=sys.stdout)
        pass
    finally:
        cursor.close()

    f.close()

from . import handlers
